﻿<cfcomponent 
	displayname="public.service.helper.tagLDAP" 
	hint="CFLDAP Tag Operation Helper" 
	output="false">
	
	<cffunction name="init" access="public" returntype="public.service.helper.tagLDAP" hint="初始化对象">
		<cfreturn this />
	</cffunction>
	
	<cffunction name="query" access="public" returntype="any" hint="查询LDAP对象">
		<cfargument name="server" type="string" required="yes" hint="LDAP 服务器地址" />
		<cfargument name="port" type="numeric" required="yes" hint="LDAP 服务器端口" />
		<cfargument name="username" type="string" required="yes" hint="用户名" />
		<cfargument name="password" type="string" required="yes" hint="用户密码" />
		
		<cfargument name="start" type="string" required="yes" hint="用户过滤条件" />
		<cfargument name="filter" type="string" required="no" default="objectclass=*" hint="用户过滤条件" />
		<cfargument name="attributes" type="string" required="yes" default="*" hint="查询属性" />
		
		<cfset var result = queryNew(attributes) />

		<cfldap name="result" action="query" timeout="30" 
			server="#arguments.server#" port="#arguments.port#" 
			username="#arguments.username#" password="#arguments.password#"
			start="#arguments.start#" filter="#arguments.filter#" attributes="#arguments.attributes#" />
		
		<cfreturn result />
	</cffunction>
	
	<cffunction name="update" access="public" returntype="void" hint="更新LDAP对象属性">
		<cfargument name="server" type="string" required="yes" hint="LDAP 服务器地址" />
		<cfargument name="port" type="numeric" required="yes" hint="LDAP 服务器端口" />
		<cfargument name="username" type="string" required="yes" hint="用户名" />
		<cfargument name="password" type="string" required="yes" hint="用户密码" />
		
		<cfargument name="dn" type="string" required="yes" hint="要更正用户的DN" />
		<cfargument name="attributes" type="string" required="yes" hint="属性值key=value" />
		
		<cfldap action="modify" modifytype="replace" timeout="30"  
			attributes="#arguments.attributes#" 
			dn="#arguments.dn#" 
			server="#arguments.server#" port="#arguments.port#" 
			username="#arguments.username#" password="#arguments.password#" />
		
	</cffunction>
	
</cfcomponent>